# 通过json发送一张图片数据
import requests
import base64
import json
import cv2


if __name__ == '__main__':
    # f = open(r'/home/amax/darknet/scripts/VOCdevkit/VOC2007/JPEGImages/08.56.43[A][0@0][0].jpg', 'rb')
    f = open(r'/home/amax/Downloads/01_604.jpg', 'rb')# 图片路径
    img_base64 = base64.urlsafe_b64encode(f.read())
    #print('type(img_base64)=',type(img_base64))
    payload = {
               'image_base64': img_base64,
               }
    #print('type(payload)=',type(payload))
    # r = requests.post(r'http://47.101.191.55:6666/', data=payload)
    r = requests.post(r'http://127.0.0.1:6666/', data=payload)# 第一个参数为目标服务器的ip与端口号，如果是本地，则不需要更改
    # print(type(r))
    r = r.text
    r = list(map(str, r))
    
    class_index = r.index('s')
    print('class is ',r[class_index+6]+r[class_index+7])
    #print('r=',r(r_class_index+2),r(r_class_index+3))
    

